from __future__ import absolute_import
#import os
import logging
from forest.tools.system.execute import run
from forest.registry import register_tool
from forest.tool import Tool

logger = logging.getLogger('forest.tools.system.dd')

@register_tool('system.dd')
def dd(iff, out, block, count, skip = None):
    ''' simple wrapper around a dd call

        TODO: clear up usage and defaults
    '''
    Tool.SIGNAL_TOOL_START(dd, level = logging.DEBUG, message = 'DD if=%s out=%s bs=%s count=%s' % (iff, out, block, count))

    args = ['dd', 'if=%s' % iff, 'of=%s' % out, 'bs=%s' % block, 'count=%s' % count]
    args.append('skip=%s' % skip)

    run(args)
